package com.woniuxy.dudugua.service.impl;

import com.woniuxy.dudugua.entity.Person;
import com.woniuxy.dudugua.entity.Product;
import com.woniuxy.dudugua.entity.User;
import com.woniuxy.dudugua.mapper.*;
import com.woniuxy.dudugua.service.DataStatisticsService;
import com.woniuxy.dudugua.util.view.OrderNumberView;
import com.woniuxy.dudugua.util.view.ProductSkuNumberView;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DataStatisticsServiceImpl implements DataStatisticsService {
    @Resource
    private UserMapper  userMapper;
    @Resource
    private PersonMapper  personMapper;
    @Resource
    private ProductMapper  productMapper;
    @Resource
    private ProductSkuMapper  productSkuMapper;
    @Resource
    private OrderMapper  orderMapper;

    @Override
    public long selectByUserNumber() throws Exception {
        long userNumber = userMapper.countByExample(null);
        if(userNumber!=0){
            return userNumber;
        }
        return 0;
    }

    @Override
    public long selectByPersonNumber() throws Exception {
        long personNumber = personMapper.countByExample(null);
        if (personNumber!=0) {
            return personNumber;

        }
        return 0;
    }

    @Override
    public List<Product> selectByProductStoreId() throws Exception {
        List<Product> productsStoreId = productMapper.selectByProductStoreId();
        if(productsStoreId!=null){
            return  productsStoreId;
        }
        return null;
    }

    @Override
    public List<ProductSkuNumberView> selectByProductSkuNumber() throws Exception {
        List<ProductSkuNumberView> productSkuNumberViews = productSkuMapper.selectByProductSkuNumber();
        if(productSkuNumberViews!=null){
            return  productSkuNumberViews;
        }
        return null;
    }

    @Override
    public List<OrderNumberView> selectByOrderNumber() throws Exception {
        List<OrderNumberView> orderNumberViews = orderMapper.selectByOrderNumber();
        if(orderNumberViews!=null){
            return  orderNumberViews;
        }
        return null;
    }
}
